﻿using Newtonsoft.Json;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.Mvc;
using BLL;

namespace OASystem.Controllers
{
    [App_Start.LoginFilterAtrribute]
    public class MainController : Controller
    {

        public ActionResult Index()
        {
            return View();
        }


        public ActionResult LoginOut()
        {
            Session["info"] = null;
            return Redirect("/Login/Index");
        }

        #region MyRegion
        //public JsonResult GetJsonArray()
        //{
        //    Common.RedisHelper redis = new Common.RedisHelper();
        //    var list = redis.GetValue<List<BLL.ExpandClass>>("dyList");
        //    if (list == null)
        //    {
        //        list = BLL.EmployeeManager.QueryDepartmentCount();
        //        var result = redis.SetValue<List<BLL.ExpandClass>>("dyList", list);
        //    }



        //    object[] array = new object[list.Count];
        //    if (list.Count != 0)
        //        for (int i = 0; i < list.Count; i++)
        //        {
        //            array[i] = list[i];
        //        }
        //    var AA = JsonConvert.SerializeObject(array);
        //    return Json(JsonConvert.SerializeObject(array));
        //} 
        #endregion


        public JsonResult GetJsonArray()
        {
            List<Group> list = new BLL.PunchManager().Query();

            Group[] obj = new Group[list.Count];

            for (int i = 0; i < list.Count; i++)
            {

                obj[i] = list[i];

            }



            var aa = JsonConvert.SerializeObject(obj);

            return Json(JsonConvert.SerializeObject(obj));


        }

    }
}
